// udpsender.h
#ifndef UDPSENDER_H
#define UDPSENDER_H
#include <QObject>
#include <QUdpSocket>
#include <QHostAddress>
#include "protocol.h"

class UdpSender : public QObject {
    Q_OBJECT
public:
    UdpSender(const QHostAddress& ip, quint16 port, QObject* parent = nullptr);
    void sendCar1(const CarData& data);
    void sendCar2(const CarData& data);
    void sendDrone(const DroneData& data);

private:
    QUdpSocket* m_socket;
    QHostAddress m_ip;
    quint16 m_port;

    void sendPacket(quint8 source, const QByteArray& payload);
    quint8 calculateChecksum(const quint8* data, quint8 length);
};
#endif
